#!/bin/bash

# Determine directory for scripts
DIR=`dirname $0`

# Load config
source "$DIR/lweamonit_config.sh"

# If we should be disabled, exit with a success code
if [ $MJPG_STREAMER_DISABLED -eq 1 ]; then
	exit 0;
fi

# Check if screens are found already
PROCESSES=`screen -list | grep "$SCREEN_NAME" | wc -l`

# If we didn't find any
if [ $PROCESSES -lt 1 ]; then
	# Start screen and the start_mjpg_streamer.sh inside it
	bash -c "$SCREEN $SCREEN_PARAMS $DIR/start_mjpg_streamer.sh"

	# Say we needed to start it
	echo "Did not find screen with mjpg_streamer, started one."
fi
